package com.sikao.app.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.sikao.app.R;
import com.sikao.app.bean.CreditRecordBean;
import com.sikao.app.utils.TimeUtil;

import java.util.List;

/**
 * Created by y50 on 2016/5/13.
 */
public class CreditRecordAdapter extends BaseAdapter {

	private Context context;
	private List<CreditRecordBean.ResBean.ListBean> beans;
	public CreditRecordAdapter(Context context,List<CreditRecordBean.ResBean.ListBean> beans){
		this.context = context;
		this.beans = beans;
	}
	@Override
	public int getCount() {
		return beans.size();
	}

	@Override
	public Object getItem(int position) {
		return null;
	}

	@Override
	public long getItemId(int position) {
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		View view;
		ViewHolder holder;
		if (convertView == null){
			view = View.inflate(context, R.layout.credit_record_list_item,null);
			holder = new ViewHolder(view);
			view.setTag(holder);
		}else{
			view = convertView;
			holder = (ViewHolder) view.getTag();
		}
		holder.remarktv.setText(beans.get(position).getRemark());
		holder.timetv.setText(TimeUtil.timeStampToTime(beans.get(position).getAdd_time(),TimeUtil.fotmatString2));
		holder.typetv.setText(beans.get(position).getType());
		holder.amounttv.setText(beans.get(position).getCredit());
		return view;
	}

	public class ViewHolder {
		public final TextView typetv;
		public final TextView amounttv;
		public final TextView timetv;
		public final TextView remarktv;
		public final View root;

		public ViewHolder(View root) {
			typetv = (TextView) root.findViewById(R.id.type_tv);
			amounttv = (TextView) root.findViewById(R.id.amount_tv);
			timetv = (TextView) root.findViewById(R.id.time_tv);
			remarktv = (TextView) root.findViewById(R.id.remark_tv);
			this.root = root;
		}
	}
}
